package org.ytor.core.sqlflow.log;

/**
 * created by yangtong on 2025/8/13 17:47:54
 * <br/>
 * SQL引擎，日志记录器
 */
public class SqlLogHelper {

    /**
     * 颜色
     */
    public static final String BLACK = "\u001B[30m";
    public static final String RED = "\u001B[31m";
    public static final String GREEN = "\u001B[32m";
    public static final String YELLOW = "\u001B[33m";
    public static final String BLUE = "\u001B[34m";
    public static final String MAGENTA = "\u001B[35m";
    public static final String CYAN = "\u001B[36m";
    public static final String WHITE = "\u001B[37m";
    // 前景 90–97
    public static final String BRIGHT_BLACK = "\u001B[90m";
    public static final String BRIGHT_RED = "\u001B[91m";
    public static final String BRIGHT_GREEN = "\u001B[92m";
    public static final String BRIGHT_YELLOW = "\u001B[93m";
    public static final String BRIGHT_BLUE = "\u001B[94m";
    public static final String BRIGHT_MAGENTA = "\u001B[95m";
    public static final String BRIGHT_CYAN = "\u001B[96m";
    public static final String BRIGHT_WHITE = "\u001B[97m";
    // 背景 100–107
    public static final String BG_BRIGHT_BLACK = "\u001B[100m";
    public static final String BG_BRIGHT_RED = "\u001B[101m";
    public static final String BG_BRIGHT_GREEN = "\u001B[102m";
    public static final String BG_BRIGHT_YELLOW = "\u001B[103m";
    public static final String BG_BRIGHT_BLUE = "\u001B[104m";
    public static final String BG_BRIGHT_MAGENTA = "\u001B[105m";
    public static final String BG_BRIGHT_CYAN = "\u001B[106m";
    public static final String BG_BRIGHT_WHITE = "\u001B[107m";

    /**
     * 样式
     */
    public static final String RESET = "\u001B[0m";
    public static final String BOLD = "\u001B[1m";
    public static final String DIM = "\u001B[2m";
    public static final String ITALIC = "\u001B[3m";
    public static final String UNDERLINE = "\u001B[4m";
    public static final String BLINK = "\u001B[5m";
    public static final String REVERSE = "\u001B[7m";
    public static final String HIDDEN = "\u001B[8m";
    public static final String STRIKE = "\u001B[9m";

    private static SqlLog sqlLog;

    /**
     * 初始化日志记录器
     */
    public static void initSqlLog(SqlLog sqlLog) {
        if (SqlLogHelper.sqlLog == null) {
            SqlLogHelper.sqlLog = sqlLog;
        }
    }

    public static SqlLog getSqlLog() {
        return SqlLogHelper.sqlLog;
    }

    public static void error(String s, Throwable e) {
        if (sqlLog != null) {
            sqlLog.error(s, e);
        }
    }

    public static void error(String s, Object... args) {
        if (sqlLog != null) {
            sqlLog.error(s, args);
        }
    }

    public static void info(String s, Object... args) {
        if (sqlLog != null) {
            sqlLog.info(s, args);
        }
    }

    public static void warn(String s, Object... args) {
        if (sqlLog != null) {
            sqlLog.warn(s, args);
        }
    }

    public static void debug(String s, Object... args) {
        if (sqlLog != null) {
            sqlLog.debug(s, args);
        }
    }

    public static void trace(String s, Object... args) {
        if (sqlLog != null) {
            sqlLog.trace(s, args);
        }
    }

}
